<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="p" uri="/WEB-INF/tld/pagination.tld"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<title>收支类别</title>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/css/public.css">
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/sorttable.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/public.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/date1.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/baseset.js"></script>
		<script type="text/javascript">
		function getIncomeExpenseByCondition(){			
			var formname = document.getElementById("IncomeExpenseForm");//form的ID
			formname.action = "getIncomeExpenseByCondition.action";
			formname.submit();
		}
		
			//修改用户和用户组
		function editIncomeExpense(){
			var incomeExpenseIDs = document.getElementsByName("incomeExpenseId");
			
			var editID="";
			var formname = document.getElementById("IncomeExpenseForm");//formd的ID

			var incomeExpenseIDCount = 0;
			
	
			for (var i = 0; i < incomeExpenseIDs.length; i++) {
				if (incomeExpenseIDs[i].checked) {
					incomeExpenseIDCount++;
					editID = editID+incomeExpenseIDs[i].value+",";
				}
			}
	
			if (incomeExpenseIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			var array = editID.split(",");	
	 		if (incomeExpenseIDCount >1) {
				alert("每次修改只能选择一条记录！");
				return false;
			} else {
				if (incomeExpenseIDCount == 1) {
					if (confirm("确认要修改该记录吗？")) {
						formname.action = "showEditIncomeExpense.action?editIncomeExpenseID="+array[0];
						formname.submit();
					}
				}
				
			} 	
		}
		
		//删除收支类别
		function deleteIncomeExpense(){
			var incomeExpenseIDs = document.getElementsByName("incomeExpenseId");
			
			var deletedIncomeExpenseID="";
			
			var formname = document.getElementById("IncomeExpenseForm");//formd的ID

			var incomeExpenseIDCount = 0;
			
	
			for (var i = 0; i < incomeExpenseIDs.length; i++) {
				if (incomeExpenseIDs[i].checked) {
					incomeExpenseIDCount++;
					deletedIncomeExpenseID = deletedIncomeExpenseID+incomeExpenseIDs[i].value+",";
				}
			}
				if (incomeExpenseIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (confirm("确认要删除记录吗？")) {
				formname.action = "deleteIncomeExpense.action?deletedIncomeExpenseID="+deletedIncomeExpenseID;
				formname.submit();
			}
		}
		
		//禁用收支类别
		function forbidIncomeExpense(){
			var incomeExpenseIDs = document.getElementsByName("incomeExpenseId");
			
			var forbidIncomeExpenseID="";
			
			var formname = document.getElementById("IncomeExpenseForm");//formd的ID

			var incomeExpenseIDCount = 0;
			
	
			for (var i = 0; i < incomeExpenseIDs.length; i++) {
				if (incomeExpenseIDs[i].checked) {
					incomeExpenseIDCount++;
					forbidIncomeExpenseID = forbidIncomeExpenseID+incomeExpenseIDs[i].value+",";
				}
			}
				if (incomeExpenseIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (confirm("确认要禁用记录吗？")) {
				formname.action = "forbidIncomeExpense.action?forbidIncomeExpenseID="+forbidIncomeExpenseID;
				formname.submit();
			}
		}
		
		//反禁用收支类别
		function antiForbidIncomeExpense(){
			var incomeExpenseIDs = document.getElementsByName("incomeExpenseId");			
			var forbidIncomeExpenseID="";			
			var formname = document.getElementById("IncomeExpenseForm");//formd的ID
			var incomeExpenseIDCount = 0;			
	
			for (var i = 0; i < incomeExpenseIDs.length; i++) {
				if (incomeExpenseIDs[i].checked) {
					incomeExpenseIDCount++;
					forbidIncomeExpenseID = forbidIncomeExpenseID+incomeExpenseIDs[i].value+",";
				}
			}
			if (incomeExpenseIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (confirm("确认要禁用记录吗？")) {
				formname.action = "antiForbidIncomeExpense.action?forbidIncomeExpenseID="+forbidIncomeExpenseID;
				formname.submit();
			}
		}
		</script>
	</head>
	<body>
		<div id="info_all">
			<div id="info_top">
				收支类别
			</div>
			<s:form name="IncomeExpenseForm" theme="simple"
				cssStyle="margin-top:0px" id="IncomeExpenseForm">
				<div id="btn">
					<input type="button" value="新增" onClick="showAddIncomeExpense()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="修改" onClick="editIncomeExpense()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="删除" onClick="deleteIncomeExpense()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="禁用" onClick="forbidIncomeExpense()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="反禁用"
						onClick="antiForbidIncomeExpense()" onFocus="this.blur()"
						onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
				</div>
				<div id="info_main">
					<div id="select">
						<hr>
						<table>
							<tr>
								<td>
									代码&nbsp;
								</td>
								<td>
									<input type="text" name="incomeExpenseCode" size="12">
									&nbsp;&nbsp;&nbsp;
								</td>
								<td>
									名称&nbsp;
								</td>
								<td>
									<input type="text" name="incomeExpenseName" size="12">
									&nbsp;&nbsp;&nbsp;
								</td>
							</tr>
						</table>
					</div>
					<div class="sele">
						<input type="button" value="查询" onFocus="this.blur()"
							onmouseover="this.className='btnover'"
							onmouseout="this.className='btnout'" class="btnsize"
							onClick="getIncomeExpenseByCondition()" />
						<input type="reset" value="重置" onFocus="this.blur()"
							onmouseover="this.className='btnover'"
							onmouseout="this.className='btnout'" class="btnsize" />
						<hr>
					</div>
					<!-- 信息显示栏 -->
					<div id="info_info2">
						<table width="700px" cellpadding="1" cellspacing="1"
							class="sortable" id="info_table">
							<thead>
								<tr>
									<th>
										<input type="checkbox" onClick="selectAll()" />
									</th>
									<th width="100px">
										代码
									</th>
									<th width="100px">
										名称
									</th>
									<th width="140px">
										全称
									</th>
									<th width="100px">
										科目
									</th>
									<th width="100px">
										类别
									</th>
									<th width="100px">
										是否禁用
									</th>
								</tr>
							</thead>
							<tbody id="mbody">
								<s:iterator value="incomeExpenseList">
									<tr>
										<td>
											<input type="checkbox" name="incomeExpenseId"
												id="incomeExpenseId" value="${incomeExpenseId}" />
										</td>
										<td>
											<s:property value="incomeExpenseCode" />
										</td>
										<td>
											<s:property value="incomeExpenseName" />
										</td>
										<td>
											<s:property value="incomeExpenseDesc" />
										</td>
										<td>
											<s:property value="accountBookName" />
										</td>
										<td>
											<s:property value="incomeExpenseType" />
										</td>
										<td>
											<s:property value="forbidden" />
										</td>
									</tr>
								</s:iterator>
							</tbody>
							<tfoot>
							</tfoot>
						</table>
 							<s:if test="!incomeExpenseList.isEmpty">
							<tr style="font-size: 12px;">
								<div align="center">
									<font color="#FF0000"> 共<s:property value="page.total" /> 页 第
										<s:property value="page.cpage" /> 页 <p:page cpage="%{page.cpage}"
											total="%{page.total}" url="%{page.url}" /> </font>
								</div>
							</tr>
						</s:if>
					</div>
				</div>
			</s:form>
		</div>
	</body>
</html>
